package com.kongxx.freemarkstudy.directive.assign;

import java.io.File;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;

public class AssignExample {
	public static void main(String[]args) throws Exception {
		// Create a configuration instance
		Configuration cfg = new Configuration();
		File file = new File(AssignExample.class.getResource("").getFile());
		cfg.setDirectoryForTemplateLoading(file);
		cfg.setObjectWrapper(new DefaultObjectWrapper());
		
		// Create a data model
		Map root = new HashMap();
		
		// Get the template
		Template temp = cfg.getTemplate("assign.ftl"); 
		
		// Merging the template with the data model
		Writer out = new OutputStreamWriter(System.out);
		temp.process(root, out);
		out.flush();  
	}
}
